TK!2
=v
#1
:n
cost
:v
1003.00058667407
:s
o
:c
annual cost of pipe, pump and pumping
#2
:n
L
:v
1000
:s
i
:u
ft
:d
ft
:c
pipe legth
#3
:n
Q
:v
20
:s
i
:u
gpm
:d
gpm
:c
fluid rate
#4
:n
D
:v
1.11726318496609
:s
o
:u
in
:d
in
:c
pipe diameter
#5
:n
d
:v
.00001
:s
i
:c
increment
=u
=l
#1
:n
D_2nd
:d
in
:u
in
:v
.25
.287044475701847
.329578124123792
.378414319367648
.43448695960383
.498868326075083
.572789588409921
.657664348370408
.755115672263122
.867007128956061
.9954784270438231
1.14298633265317
1.31235165036323
1.50681316565986
1.7300895804699
1.98645062617284
2.28079871398955
2.6187626841543
3.00680544664253
3.45234757187584
3.96390919483858
4.55127294624867
5.22567102652779
6
E
#2
:n
cost_2nd
:v
21205.4373495424
12595.8937891136
7728.88473512323
4934.24895009567
3302.63727668545
2334.56548145275
1752.77070836336
1401.48029361543
1192.06099357184
1073.50742622561
1016.29662149917
1003.48090026427
1025.73468169597
1078.58724777611
1160.88510705895
1273.96413909939
1421.24817681271
1608.12016109254
1841.98410303459
2132.47737898075
2491.81767143739
2935.28494083424
3481.85048114449
4154.97484179372
E
=f
#1
:n
piping
:c
Objective function example
:t
Rule
:p
L,Q
:a
D
:v
cost
#1
:n
piping
:z
cost = .45*L + .245*L*D^1.5 + 325*sqrt(hp) + 61.6*hp^.925 + 102
hp = L * (4.4e-8*Q^3/D^5 + 1.92e-9*Q^2.68/D^4.68)
/E
E
=r
#1
:r
"  ***  Single-variable Optimization, Part 2  ***
:s
C
#3
:r
cost = piping(D)
:s
C
#4
:r
cost = piping(D+d)
:s
C
#6
:r
" The first rule above evaluates the objective function  cost  as depending
:s
C
#7
:r
" on  D  (see the formulation of the problem in model OPTIM1A and/or press
:s
C
#8
:r
" F7 to display the graph of the objective function).
:s
C
#10
:r
" The second rule in conjunction with the first represents the equality
:s
C
#11
:r
" piping(D) = piping(D+d) , which is equivalent to equating an approximate
:s
C
#12
:r
" derivative of  cost  with respect to  D  to zero, that is, in general form,
:s
C
#14
:r
"                 d f(x)       f(x+dx) - f(x)
:s
C
#15
:r
"                ÄÄÄÄÄÄÄÄ  ÷  ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ  =  0
:s
C
#16
:r
"                  d x               dx
:s
C
#18
:r
" After assigning input value  d=.00001  and guess  D=1 , uncancelling the
:s
C
#19
:r
" above two rules, and pressing F9, the solution comes up in 5 iteration 
:s
C
#20
:r
" steps.
:s
C
#22
:r
" This is the quickest and simplest way to perform one-dimensional optimi-
:s
C
#23
:r
" zation in TK.  The second derivative of the objective function must be
:s
C
#24
:r
" monotonic in the vicinity of the initial guess and the optimum point,
:s
C
#25
:r
" i.e. the graph must be similar to a parabola so that the Iterative Solver
:s
C
#26
:r
" converges to the correct solution.  
:s
C
#28
:r
" Another sensitive point is the selection of the increment  d .  If it is
:s
C
#29
:r
" too large, the solution is imprecise; if it is too small, and if the guess
:s
C
#30
:r
" is close to the solution, the error function used by the Iterative Solver
:s
C
#31
:r
" may not be large enough to trigger the iteration process, and the guess
:s
C
#32
:r
" is misleadingly returned as a solution.  The simplest way of using this
:s
C
#33
:r
" inexpensive method is to find the smallest feasible  d  for a given problem
:s
C
#34
:r
" or class of problems by trial.
:s
C
=p
#1
:n
second
:t
Line chart
:d
EGA
:i
""
:s
Yes
:z
None
:g
No
:l
None
:h
"Pipe Diameter"
:v
"Cost"
:x
D_2nd
:u
#1
:y
cost_2nd
:f
1
:p
Lines
:c
"*"
E
=t
=n
=g
#1
:c
.000001
:i
10
:v
Yes
:l
60
:f
66
:m
0
:w
80
:b
Yes
:a
Yes
:r
Yes
:h
No
:t
1
:n
Yes
:d
LPT1
%Tr,f,0,1,0,1,0
